package org.xjc.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author : XJC
 * @Description :菜单：控制路由和该栏菜单下面的所有API URL
 * @create : 2022/8/27 9:26
 */

@Data
@NoArgsConstructor
@AllArgsConstructor

@Entity
@Table(name = "T_MENU")
@TableName("T_MENU")
public class MenuEntity extends BaseEntity {

    /**
     * 父菜单ID，一级菜单为0
     */
    @TableField("PARENT_ID")
    @Column(name = "PARENT_ID",columnDefinition = "varchar2(64)")
    private Long parentId;

    /**
     * 菜单名称
     */
    @TableField("NAME")
    @Column(name = "NAME",columnDefinition = "varchar2(64)")
    private String name;

    /**
     * 菜单URL
     */
    @TableField("URL")
    @Column(name = "URL",columnDefinition = "varchar2(64)")
    private String url;

    /**
     * 权限，只有按钮有
     */
    @TableField("PERM")
    @Column(name = "PERM",columnDefinition = "varchar2(64)")
    private String perm;

    /**
     * 前端组件名
     */
    @TableField("COMPONENT")
    @Column(name = "COMPONENT",columnDefinition = "varchar2(64)")
    private String component;

    /**
     * 类型     0：目录   1：菜单   2：按钮
     */
    @TableField("TYPE")
    @Column(name = "TYPE",columnDefinition = "number(2)")
    private Integer type;

    @TableField(exist=false)
    @Transient
    private List<MenuEntity> children;

    @TableField(exist=false)
    @Transient
    private List<RoleEntity> roles;

}
